package com.taotao.rest.controller;

import com.taotao.rest.pojo.CatResult;
import com.taotao.rest.service.ItemCatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.converter.json.MappingJacksonValue;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Package com.taotao.rest.controller
 * @Description:
 * @Author elwyn
 * @Date 2017/9/4 0:56
 * @Email elonyong@163.com
 */
@Controller
public class ItemCatController {

    @Autowired
    private ItemCatService itemCatService;

   /* @RequestMapping(value = "/itemcat/list",produces = MediaType.APPLICATION_JSON_VALUE+";charset=utf-8")
    @ResponseBody
    public String getItemCatList(String callback) {
        CatResult itemCatList = itemCatService.getItemCatList();
        String json = JsonUtils.objectToJson(itemCatList);
        String result = callback + "(" + json + ");";
        return result;
    }*/

    @RequestMapping(value = "/itemcat/list")
    @ResponseBody
    public MappingJacksonValue getItemCatList(String callback) {
        CatResult itemCatList = itemCatService.getItemCatList();
        MappingJacksonValue mappingJacksonValue =new MappingJacksonValue(itemCatList);
        mappingJacksonValue.setJsonpFunction(callback);
        return mappingJacksonValue;
    }


}
